import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Icon } from '/@/components/Icon';
import { render } from '/@/utils/common/renderUtils';

// 定义可选择的组件类型
export enum ComponentTypes {
  Default = 'layouts/default/index',
  IFrame = 'sys/iframe/FrameBlank',
}

export const columns: BasicColumn[] = [
  {
    title: '系统标题',
    dataIndex: 'title',
    width: 200,
    align: 'left',
  },
  {
    title: '系统名称',
    dataIndex: 'name',
    width: 200,
    align: 'left',
  },
  {
    title: '图标',
    dataIndex: 'icon',
    width: 50,
    customRender: ({ record }) => {
      return h(Icon, { icon: record.icon });
    },
  },
  {
    title: '根目录',
    dataIndex: 'basepath',
    align: 'left',
    width: 150,
  },
  {
    title: '状态',
    dataIndex: 'status_dictText',
    width: 100,
  },
  {
    title: '排序',
    dataIndex: 'orders',
    width: 50,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'title',
    label: '系统标题',
    component: 'Input',
    colProps: { span: 8 },
  },
];

export const formSchema: FormSchema[] = [
  {
    label: 'id',
    field: 'id',
    component: 'Input',
    show: false,
  },
  {
    field: 'title',
    label: '系统标题',
    component: 'Input',
    required: true,
  },
  {
    field: 'name',
    label: '系统名称',
    component: 'Input',
    required: true,
  },
  {
    field: 'banner',
    label: '背景图',
    component: 'Input',
  },
  {
    field: 'basepath',
    label: '根目录',
    component: 'Input',
  },
  {
    field: 'icon',
    label: '菜单图标',
    component: 'IconPicker',
  },
  {
    field: 'orders',
    label: '排序',
    component: 'InputNumber',
    defaultValue: 1,
  },
  {
    field: 'status',
    label: '是否启用',
    defaultValue: 1,
    component: 'JDictSelectTag',
    componentProps: {
      type: 'radioButton',
      dictCode: 'system_status',
      stringToNumber: true,
    },
  },
];
